<?php
class fishList {
    private $fishMap = [];
    public function addMap($name,$weight) {
        $this->fishMap[$name] = $weight;
    }

    public function getFishMap() {
        return $this->fishMap;
    }

    public function printFishMap() {
        print_r($this->fishMap);
    }
}
$FISH=[
    'Cyprinidae' => new fishList(),
    'Salmonids' => new fishList(),
    'Percidae' => new fishList(),
];

$data=[
    'liyu'=>['草鱼'=>"28kg",'鲤鱼'=>'20kg'],
    'guiyu'=>['大西洋鲑鱼'=>'30kg','湖鳟'=>'9kg'],
    'luyu'=>['鲈鱼'=>'1.5kg'],
];

foreach ($data as $k=>$v) {
    switch ($k){
        case 'liyu':
            foreach ($v as $k1=>$v1) {
                $FISH['Cyprinidae']->addMap($k1,$v1);
            }
            break;
        case 'guiyu':
            foreach ($v as $k1=>$v1) {
                $FISH['Salmonids']->addMap($k1,$v1);
            }
            break;
        case 'luyu':
            foreach ($v as $k1=>$v1) {
                $FISH['Percidae']->addMap($k1,$v1);
            }
    }
}

//echo '鲤科:';
//$Cyprinidae->printFishMap();
//echo '鲈科:';
//$Percidae->printFishMap();
//echo '鲑科:';
//$Salmonids->printFishMap();

foreach ($FISH as $FISH1) {
    $FISH1->printFishMap();
}

//$FISH[0]->printFishMap();



?>